#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef struct node {//定义链表
	char data;
	struct node* next;
}linknode;

void initiallink(linknode*& L) {//初始化单链表
	L = (linknode*)malloc(sizeof(linknode));
	L->next = NULL;
}

void tailpush(linknode*& L, char arr[], int n) {//尾插法
	linknode* ind;//终端指针
	linknode* newnode;//新节点
	ind = L;//指向头结点
	for (int i = 0; i < n; i++) {
		newnode = (linknode*)malloc(sizeof(linknode));//创建节点
		newnode->data = arr[i];
		ind->next = newnode;
		ind = newnode;
	}
	ind->next = NULL;//最后将终端节点指向空
}

void showlink(linknode*& L) {//遍历链表
	linknode* ind = L->next;//创建指针
	while (ind != NULL) {
		cout << ind->data;
		ind = ind->next;
	}
	cout << endl;
}

void checklink(linknode*& L, int j, char &x) {//查看链表元素
	linknode* ind = L;
	for (int i = 0; i < j; i++) {
		ind = ind->next;
	}
	x = ind->data;
}

void deletelink(linknode*& L, int j) {//删除链表元素
	linknode* ind = L;
	linknode* drop;
	for (int i = 0; i < j - 1; i++) {
		ind = ind->next;
	}
	drop = ind->next;
	ind->next = drop->next;
	free(drop);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	linknode* h;
	char x;
	char arr[5] = { 'a','b','c','d','e' };
	initiallink(h);
	tailpush(h, arr, 5);
	showlink(h);
	checklink(h, 3, x);
	cout << x << endl;
	deletelink(h, 3);
	showlink(h);
	return 0;
}
